home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-07-02 | 1.2 KB | 40 lines | [TEXT/ToyS] |
- property MyData : 0 --The data I store (persistent, remember!)
- property OriginalData : 0 --Backup copy of data as of the time I was launched
- property modified : false --Has MyData been changed since I was launched?
-
- on run
- copy MyData to OriginalData -- Keep a backup
- set modified to false
- end run
-
- -- Call store from another script to store a piece of data
- on store(value)
- if (value ≠ MyData) then
- copy value to MyData
- set modified to true
- end if
- return value
- end store
-
- -- Call retrieve from another script to retrieve the stored data
- on retrieve()
- return MyData
- end retrieve
-
- -- Confirm quit
- on quit
- if modified then
- display dialog "Save changes to the script’s data before quitting?" ¬
- with icon caution ¬
- buttons {"Don’t Save", "Cancel", "Save"} ¬
- default button "Save"
- --If the user presses Cancel, the script will fail silently,
- --and the application's Quit handler will not run.
- if the button returned of result is not "Save" then
- copy OriginalData to MyData --Restore the backup
- end if
- set modified to false
- end if
- copy 0 to OriginalData --No need to store 2 copies in the file!
- continue quit --This makes the application actually quit
- end quit